home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / tclx7_31.z / tclx7_31 / tcldev / tclX7.3a-p1 / tests / msgcat.test < prev    next >
Encoding:
Text File  |  1994-01-23  |  3.3 KB  |  112 lines

  1. #
  2. # msgcat.test
  3. #
  4. # Tests for the XPG/3 message catalog commands.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992-1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: msgcat.test,v 3.0 1993/11/19 06:57:56 markd Rel $
  16. #------------------------------------------------------------------------------
  17.  
  18. if {[info procs test] != "test"} then {source testlib.tcl}
  19.  
  20. #
  21. # This only tests default strings, since its difficult to setup and rely on
  22. # a message catalog being present.  This will work on systems without message
  23. # catalogs, as the stubs return default strings.
  24. #
  25.  
  26. Test message-cat-1.1 {catopen tests} {
  27.     set msgcat [catopen "FOOBAZWAP"]
  28.     catclose $msgcat 
  29.     crange $msgcat 0 5
  30. } 0 {msgcat}
  31.  
  32.  
  33. Test message-cat-1.2 {catopen tests} {
  34.     set msgcat [catopen -nofail "FOOBAZWAP"]
  35.     catclose $msgcat 
  36.     crange $msgcat 0 5
  37. } 0 {msgcat}
  38.  
  39.  
  40. Test message-cat-1.3 {catopen tests} {
  41.     list [catch {catopen -fail "FOOBAZWAP"} msg] $msg
  42.     case $msg {
  43.         {"open of message catalog failed"} {concat "OK"}
  44.         {"the message catalog facility is not available, default string is always returned"} {concat "OK"}
  45.         default {concat "Bad catopen return: $msg"}
  46.     }
  47. } 0 {OK}
  48.  
  49. Test message-cat-2.1 {catclose tests} {
  50.     set msgcat [catopen "FOOBAZWAP"]
  51.     catclose $msgcat 
  52.     catgets $msgcat
  53. } 1 {wrong # args: catgets catHandle setnum msgnum defaultstr}
  54.  
  55.  
  56. Test message-cat-2.2 {catclose tests} {
  57.     set msgcat [catopen "FOOBAZWAP"]
  58.     catclose $msgcat
  59. } 0 {}
  60.  
  61. Test message-cat-2.3 {catclose tests} {
  62.     set msgcat [catopen "FOOBAZWAP"]
  63.     catclose -nofail $msgcat
  64. } 0 {}
  65.  
  66. Test message-cat-2.4 {catclose tests} {
  67.     set msgcat [catopen "FOOBAZWAP"]
  68.     catclose $msgcat 
  69.     catclose -fail $msgcat
  70. } 1 {msgcat is not open}
  71.  
  72.  
  73. Test message-cat-2.5 {catclose tests} {
  74.     catclose baz
  75. } 1 {invalid msgcat handle: baz}
  76.  
  77. Test message-cat-2.6 {catclose tests} {
  78.     catclose
  79. } 1 {wrong # args: catclose ?-fail|-nofail? catHandle}
  80.  
  81.  
  82. Test message-cat-3.1 {catgets tests} {
  83.     set msgcat [catopen "FOOBAZWAP"]
  84.     catgets $msgcat 1 12 "This is a test"
  85. } 0 {This is a test}
  86. catch {catclose $msgcat}
  87.  
  88. Test message-cat-3.2 {catgets tests} {
  89.     set msgcat [catopen "FOOBAZWAP"]
  90.     catgets $msgcat 101 12 "This is an actual emergency"
  91. } 0 {This is an actual emergency}
  92. catch {catclose $msgcat}
  93.  
  94. Test message-cat-3.3 {catgets tests} {
  95.     set msgcat [catopen "FOOBAZWAP"]
  96.     catclose $msgcat 
  97.     catgets $msgcat 101 12 "This is an actual emergency"
  98. } 1 {msgcat is not open}
  99.  
  100. Test message-cat-3.4 {catgets tests} {
  101.     set msgcat [catopen "FOOBAZWAP"]
  102.     catgets $msgcat xx 12 "This is an actual emergency"
  103. } 1 {expected integer but got "xx"}
  104. catch {catclose $msgcat}
  105.  
  106. Test message-cat-3.5 {catgets tests} {
  107.     set msgcat [catopen "FOOBAZWAP"]
  108.     catgets $msgcat 102 "This is an actual emergency"
  109. } 1 {wrong # args: catgets catHandle setnum msgnum defaultstr}
  110. catch {catclose $msgcat}
  111.  
  112.